﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Brain
{
    public partial class BinaryFileReader : Form
    {
        public BinaryFileReader()
        {
            InitializeComponent();
        }

        private void button_Search_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            if (open.ShowDialog() == DialogResult.OK)
            {
                this.text_FileName.Text = open.FileName;

                using (FileStream fs = new FileStream(open.FileName, FileMode.Open, FileAccess.Read))
                {
                    BinaryReader br = new BinaryReader(fs);
                    long numBytes = new FileInfo(open.FileName).Length;
                    byte[] buff = br.ReadBytes((int)numBytes);

                    string s = ArrayUtil.ConvertArrayToCSHarpCode<byte>(buff, "File");
                    this.text_Result.Text = s;

                    br.Dispose();
                }
            }
        }
    }
}
